﻿package mortal.game.resource.tableConfig
{
    import Message.DB.Tables.*;
    import com.gengine.resource.*;
    import flash.utils.*;
    import mortal.game.view.common.*;

    public class RobotConfig extends Object
    {
        private var _robotDic:Dictionary;
        private static var _instance:RobotConfig;

        public function RobotConfig()
        {
            this._robotDic = new Dictionary();
            if (_instance != null)
            {
                throw new Error(" RobotConfig 单例 ");
            }
            this.init();
            return;
        }// end function

        private function write(param1:Object) : void
        {
            var _loc_2:TRobot = null;
            var _loc_3:Object = null;
            for each (_loc_3 in param1)
            {
                
                _loc_2 = new TRobot();
                ClassTypesUtil.copyValue(_loc_2, _loc_3);
                this._robotDic[_loc_2.code] = _loc_2;
            }
            return;
        }// end function

        private function init() : void
        {
            var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_robot.json");
            this.write(_loc_1);
            return;
        }// end function

        public function getRobotByCode(param1:int) : TRobot
        {
            return this._robotDic[param1];
        }// end function

        public function getRobotByPetCode(param1:int) : TRobot
        {
            var _loc_2:TRobot = null;
            for each (_loc_2 in this._robotDic)
            {
                
                if (_loc_2.petCode == param1)
                {
                    return _loc_2;
                }
            }
            return null;
        }// end function

        public static function get instance() : RobotConfig
        {
            if (_instance == null)
            {
                _instance = new RobotConfig;
            }
            return _instance;
        }// end function

    }
}
